<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:ui="http://java.sun.com/jsf/facelets">
 



<h:outputText id="status"/><br/>
 
<script type="text/javascript" src="static/js/gears_init.js"></script> 
<script type="text/javascript" src="static/js/sample.js"></script> 
<script> 
 
  init();
 
  function init() {
    if (!window.google || !google.gears) {
    	addStatus('Gears is not installed', 'error');
    return;
  }
 
  addStatus('Getting location...');
 
  function successCallback(p) {
    var address = p.gearsAddress.city + ', '
                  + p.gearsAddress.region + ', '
                  + p.gearsAddress.country + ' ('
                  + p.latitude + ', '
                  + p.longitude + ')';
 
    clearStatus();
    addStatus(address);
  }
 
  function errorCallback(err) {
    var msg = 'Error retrieving your location: ' + err.message;
    setError(msg);
  }
 
  try {
    var geolocation = google.gears.factory.create('beta.geolocation');
    geolocation.getCurrentPosition(successCallback,
                                   errorCallback,
                                   { enableHighAccuracy: true,
                                     gearsRequestAddress: true });
  } catch (e) {
    setError('Error using Geolocation API: ' + e.message);
    return;
  }
 
}
</script> 
</html>
